<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>设备列表</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style type="text/css">
    html,body{
        height: 100%;
        margin: 0
    }

   .header_return{
    background-image: url(../image/we_return.png);
    background-repeat: no-repeat;
    background-size: 18px 23px;
    background-position: center;
    width: 45px;
    height: 100%;
    display: block;
   }
   .header_context{
     font-size: 18px;
     color:#fff;
     text-align: center;
     line-height:45px;
     -webkit-box-flex:1.0;
     display: block;
   }
   .header_right{
    width: 11%;
    height: 100%;
    background-image: url(../image/menu_white.png);
    background-repeat: no-repeat;
    background-size: 20px 20px;
    background-position: center;
    display: block;

   }


    </style>
</head>
<body>

  <header style="width:100%;height:65px;background-color:#ff9900;">
     <div class="header_div" style="height:45px;display:-webkit-box;padding-top:20px;">
       <div class="header_return"></div>
       <div class="header_context">设备管理</div>
       <div class="header_right"></div>
     </div>
  </header>


</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/common.js"></script>

<script type="text/javascript">
     var phoneSystem
    apiready = function(){
     obtainNativeData()
     api.openFrame({
         name:'index_frame',
         url: './index_frame.html',
         rect: {
             x: 0,
             y: getFrameY(),
             w: api.winWidth,
             h: 'auto'
         },
         pageParam: {
             name: 'test'
         },
         bounces: true,
         bgColor: 'rgba(0,0,0,0)',
         vScrollBarEnabled: true,
         hScrollBarEnabled: true
     });


      $('.header_return').click(function(){
        api.closeWin({
        });
      })

      $('.header_right').click(function() {
          api.sendEvent({
            name: 'indexFrame_Event',
            extra: {
              type:1
           }
          });

      });
    };

    //获取原生数据
    function obtainNativeData(){
      var appdat1;
      phoneSystem = api.systemType;
      if ('android' === phoneSystem) {
          appdat1 = api.appParam;
          appdat1 = JSON.parse(appdat1);
      } else if ('ios' === phoneSystem) {
          appdat1 = api.pageParam;
      }

     console.log('.........appdat1......' + JSON.stringify(appdat1));
      var siteAreaid = appdat1.siteAreaid;
      var pattern = appdat1.pattern;
      var userId = appdat1.userId;
      var userToken = appdat1.userToken;  //package_List
      var appFWQ = appdat1.appFWQ;
      var package_List = appdat1.package_List;
      var deviceCount = appdat1.deviceCount;
      $api.setStorage(common.appKey.siteAreaid,siteAreaid);
      $api.setStorage(common.appKey.pattern,pattern);
      $api.setStorage(common.appKey.userId,userId);
      $api.setStorage(common.appKey.userToken,userToken);
      $api.setStorage(common.appKey.appFWQ,appFWQ);
      $api.setStorage(common.appKey.mac,appdat1.mac);
      $api.setStorage(common.appKey.apMac,appdat1.apMac);
      $api.setStorage(common.appKey.ip,appdat1.ip);
      $api.setStorage(common.appKey.vipId,appdat1.vipId);
      $api.setStorage(common.appKey.deviceCount,deviceCount);
      $api.setStorage(common.appKey.comboId,appdat1.comboId);
      $api.setStorage(common.appKey.good_tab,appdat1.good_tab);
      $api.setStorage(common.appKey.pledge,appdat1.pledge);
    }

    function getFrameY(){
      var frameheigh = $api.dom('header').offsetHeight;
      var systemType = api.systemType;
      if(api.systemType === 'ios'){
          var systemVersion = api.systemVersion;
          if(parseFloat(systemVersion) >= 11.0){
            frameheigh = frameheigh + 20;
          }
          return frameheigh;
      }
      return frameheigh;
    }

</script>
</html>
